package com.passioneffect.widgets {
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	import flash.display.Graphics;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	
	import gs.TweenMax;	

	/**
	 * @author Passion Effect
	 */
	public class SlideInMask {

		private var _time : Number = 0;
		private var _parentMC : DisplayObjectContainer;
		private var _childMC : DisplayObject;
		private var mask_mc : Sprite;
		private var opened:Boolean;
		
		public function SlideInMask(parentMC:DisplayObjectContainer,childMC:DisplayObject,time:Number=0) {
			this._time=time;	
			this._parentMC=parentMC;
			this._childMC=childMC;
			mask_mc=new Sprite();
			
			var g:Graphics=mask_mc.graphics;
			g.clear();
			g.lineStyle();
			g.beginFill(0x000000,1);
			g.drawRect(0, 0, _parentMC.width, _parentMC.height);
			g.endFill();
			
			mask_mc.mouseEnabled=false;
			_childMC.visible=false;
		}
		
		public function open():void{
		//	_childMC.mouseEnabled=false;
			if(opened)return;
			opened=true;
			
			
			_parentMC.parent.addChild(mask_mc);
			_parentMC.parent.addChild(_childMC);
			
			_childMC.mask=mask_mc;
			_childMC.visible=true;
			_childMC.y=mask_mc.height;
			TweenMax.to(_childMC,_time,{y:String(-_childMC.height)});
			
		}
		
		public function update():void{
			var g:Graphics=mask_mc.graphics;
			g.clear();
			g.lineStyle();
			g.beginFill(0x000000,1);
			g.drawRect(0, 0, _parentMC.width, _parentMC.height);
			g.endFill();
		}
		
		public function close() : void {
			//TweenMax.to(_childMC,_time,{y:mask_mc.height});
		}
		
	}
}
